###[view/StudentInfo.py]
from PySide6.QtWidgets import QVBoxLayout, QGroupBox, QLabel
from PySide6.QtCore import Slot
from model.Student import Student

class StudentInfo(QVBoxLayout):
    """学生详情展示组件（继承自QVBoxLayout）"""
    def __init__(self):
        super().__init__()
        
        # 容器组件（保持与StudentList一致的UI风格）
        self._container = QGroupBox("学生详情")
        self._container.setLayout(self)
        
        # 初始化信息标签
        self.labels = {
            "学号": QLabel("学号："),
            "姓名": QLabel("姓名："), 
            "性别": QLabel("性别："),
            "座位": QLabel("座位：")
        }
        
        # 添加标签到布局
        for label in self.labels.values():
            self.addWidget(label)
        
        self.addStretch()

    @Slot(object)
    def update_info(self, student:Student, date_str):
        """更新显示的学生信息"""
        if not student:
            return
        self.labels["学号"].setText(f"学号：{student.stu_id}")
        self.labels["姓名"].setText(f"姓名：{student.name}")
        self.labels["性别"].setText(f"性别：{student.gender}")
        self.labels["座位"].setText(f"座位：{student.seat_position}")

    #[view/StudentInfo.py]
    @Slot()
    def clear_info(self):
        """清空所有学生信息显示"""
        # 1. 重置所有标签文本
        for field, label in self.labels.items():
            label.setText(f"{field}：")  # 恢复默认占位文本

        # self._container.setStyleSheet("QGroupBox { color: gray; }")
        
